package cn.demo.test

import java.io.ObjectInputStream
import java.net.ServerSocket
import java.util.Date

import org.dk.file.ReadFile

object Executor {
  def main(args: Array[String]): Unit = {
    val dkServer = new ServerSocket(8848)
    println("dk server on port 8848")
    val client = dkServer.accept()
    val inStream = client.getInputStream
    val objectIn = new ObjectInputStream(inStream)
    val task = objectIn.readObject().asInstanceOf[Task]

    var value = s"${new Date()}\nthis is taskDK [INFO]: ${task.candace()}"
    println(value)

    val path = s"D:\\IDE\\Workspace_IDE\\spark_study\\spark_core\\src\\main\\resources\\log.txt"
    val ods = ReadFile.readFile(path)
    if (ods.length != 0) {
      value = ods + "<!--*******************-->\n" + value
    }
    LoggerSave.saveLocalLog(path, value)

    inStream.close()
    client.close()
    dkServer.close()
  }
}
